{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bc264618",
   "metadata": {},
   "source": [
    "单分支语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4647c3d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "abc\n",
      "root\n"
     ]
    }
   ],
   "source": [
    "uid = 0\n",
    "\n",
    "if uid == 0:\n",
    "    print(\"abc\")\n",
    "print(\"root\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ca04ac5",
   "metadata": {},
   "source": [
    "双分支语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "39985460",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "abc\n"
     ]
    }
   ],
   "source": [
    "if uid == None:\n",
    "    print(\"root\")\n",
    "else:\n",
    "    print(\"abc\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b19fb9b6",
   "metadata": {},
   "source": [
    "多分支语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c919cfdc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Level B\n"
     ]
    }
   ],
   "source": [
    "score = 88.8\n",
    "level = int(score%10)\n",
    "\n",
    "if level >= 10:\n",
    "    print(\"Level A+\")\n",
    "elif level == 9:\n",
    "    print(\"Level A\")\n",
    "elif level == 8:\n",
    "    print(\"Level B\")\n",
    "elif level == 7:\n",
    "    print(\"Level C\")\n",
    "elif level == 6:\n",
    "    print(\"Level D\")\n",
    "else:\n",
    "    print(\"Level E\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7879c533",
   "metadata": {},
   "source": [
    "三元条件运算符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "cf38c121",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "level other\n"
     ]
    }
   ],
   "source": [
    "print(\"level A+\") if level >= 10 else print(\"level other\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b27566d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "my_test",
   "language": "python",
   "name": "my_test"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
